﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace AdvancedStandingAndScholarship
{
    public partial class Home : Page
    {
        public Home()
        {
            InitializeComponent();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += new EventHandler(timer_Tick);
        }

        #region event handler

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            lblLoginFail.Visibility = Visibility.Collapsed;
        }

        private void btnForgetPassword_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            NavigationService.Navigate(new Uri("/ForgetPasswordPage", UriKind.Relative));
        }

        private void btnRegister_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            NavigationService.Navigate(new Uri("/RegisterPage", UriKind.Relative));
        }

        private void btnSubmit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //do login here
            String username = tbxEmail.Text;
            String password = tbxPassword.Password;

            (App.Current.RootVisual as MainUserControl).busy.Visibility = Visibility.Visible;

            timer.Start();
            NavigationService.Navigate(new Uri("/MainPage", UriKind.Relative));

            //if login fail
            lblLoginFail.Visibility = Visibility.Visible;
        }
        DispatcherTimer timer = new DispatcherTimer();
        void timer_Tick(object sender, EventArgs e)
        {
            (App.Current.RootVisual as MainUserControl).busy.Visibility = Visibility.Collapsed;
            timer.Stop();
        }

        private void btnOneTimeUser_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
        	NavigationService.Navigate(new Uri("/MainPage", UriKind.Relative));
			
        }

        #endregion
    }
}